/* Andreas Baum
 * ChatServer.java
 * Starts up a chat server, listens for new connections 
 * Starts a thread for each new user
 * CS 78 - Networks - Programming Assignment 1
 */

package ChatServer;

import java.io.IOException;
import java.net.ServerSocket;

public class ChatServer {

	/**
	 * @param args
	 */

	public static int PORT = 4444;
	public static ServerSocket serverSocket;


	public static void main(String[] args) throws IOException {
		
		// Print welcome message:
		System.out.println("Welcome the Chat Server");
		System.out.println("Starting up...");
		
		// Bind to port:
		try {
			serverSocket = new ServerSocket(PORT);
		} catch (IOException e) {
			System.out.println("ERROR: Could not listen on port: " + PORT);
			System.exit(-1);
		}
		// Output information:
		System.out.println("Listening on port " + PORT + ".");
		
		new ListenerThread(serverSocket, PORT);
		
	}
}